package com.dragon.repository.domain.dto;

import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Goods;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class GoodsDTO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "客户id")
    private Integer customerId;

    @ApiModelProperty(value = "产品名称")
    private String goodsName;

    @ApiModelProperty(value = "产品编码")
    private String goodsNum;

    @ApiModelProperty(value = "产品价格")
    private BigDecimal price;

    @ApiModelProperty(value = "产品描述(备注)")
    private String remark;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "用户id")
    private Integer adminId;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "删除标识：0未删除 1已删除")
    private Integer deleted;

    @ApiModelProperty(value = "客户名称")
    private String customerName;


    public GoodsDTO() {}

    public GoodsDTO(Goods entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static GoodsDTO convert(Goods entity) {
        return new GoodsDTO(entity);
    }

    public static List<GoodsDTO> convertList(List<Goods> list) {
        List<GoodsDTO> resultList = new ArrayList<>();
        for (Goods entity : list) {
            resultList.add(new GoodsDTO(entity));
        }
        return resultList;
    }}
